home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MyComponentRoutines.c
-
- Contains: simple component sample.
-
- Written by: John Wang
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 03/14/94 JW Re-Created for Universal Headers.
-
- To Do:
-
- */
-
- #ifdef THINK_C
- #define applec
- #endif
-
- #include <Errors.h>
- #include <Components.h>
- #include <Devices.h>
- #include <Movies.h>
- #include <QuickTimeComponents.h>
- #include <LowMem.h>
-
- #include "MyComponent.h"
- #include "MyComponentRoutines.h"
- #include "FadeScreen.h"
- #include "HideMenuBar.h"
-
- /* ------------------------------------------------------------------------- */
-
- pascal ComponentResult MyIsPlayerEvent (PrivateGlobals **storage,
- EventRecord *e)
- {
- GrafPtr savePort;
- GDHandle saveGD;
-
- // Fade out for the first time.
- if ((**storage).firstTime == true) {
- SwapWindow(storage);
- (**storage).firstTime = false;
- }
-
- // Handle events
- if (e->what == keyDown) {
- if ((e->message & charCodeMask) == '\t') {
- SwapWindow(storage);
- return(true);
- }
- } else if (e->what == updateEvt) {
- if (e->message == (long) (**storage).backWindow) {
- GetPort(&savePort);
- saveGD = GetGDevice();
- SetPort((**storage).backWindow);
- SetGDevice(GetMainDevice());
- BeginUpdate((**storage).backWindow);
- PaintRect(&(((**storage).backWindow)->portRect));
- EndUpdate((**storage).backWindow);
- SetPort(savePort);
- SetGDevice(saveGD);
- return(true);
- }
- }
-
- // Handle other events.
- return(MCIsPlayerEvent((**storage).delegate, e));
- }
-
- //--------------------------------------------------------------------------
-
- void SwapWindow(PrivateGlobals **storage)
- {
- CGrafPtr moviePort;
- GDHandle myDevice;
- Rect myDeviceRect, movieRect;
- GrafPtr savePort;
- GDHandle saveGD;
- RgnHandle movieRgn;
-
- // Get variables
- GetPort(&savePort);
- saveGD = GetGDevice();
- GetMovieGWorld(MCGetMovie((**storage).delegate), &moviePort, nil);
- myDevice = GetMaxDevice(&((**LMGetGrayRgn()).rgnBBox));
- myDeviceRect = (**myDevice).gdRect;
-
- FadeInOut(myDevice, true, 60);
- if ((**storage).fadeStatus == false) {
- // Hide the menu bar
- (**storage).handleBarStorage = HideMenuBar();
-
- // Modify movie controller.
- (**storage).mcVisible = MCGetVisible((**storage).delegate);
- (**storage).mcAttached = MCIsControllerAttached((**storage).delegate);
- MCSetVisible((**storage).delegate, false);
- // MCSetControllerAttached((**storage).delegate, false);
- movieRgn = MCGetWindowRgn((**storage).delegate, (WindowPtr) moviePort);
- SizeWindow((WindowPtr) moviePort, ((**movieRgn).rgnBBox).right - ((**movieRgn).rgnBBox).left,
- ((**movieRgn).rgnBBox).bottom - ((**movieRgn).rgnBBox).top, true);
- DisposeRgn(movieRgn);
-
- // Create back window.
- (**storage).backWindow = NewCWindow(0L, &myDeviceRect, "\pBlack Background", 1, noGrowDocProc, (WindowPtr) -1, false, 0L);
- SelectWindow((**storage).backWindow);
- SetPort((**storage).backWindow);
- SetGDevice(GetMainDevice());
- PaintRect(&(((**storage).backWindow)->portRect));
-
- // Modify movie window.
- SetPort((GrafPtr) moviePort);
- SetGDevice(GetMainDevice());
- SelectWindow((WindowPtr) moviePort);
- (**storage).fadeStatus = true;
- } else {
- // Restore menu bar.
- RestoreMenuBar((**storage).handleBarStorage);
-
- // Restore movie controller.
- MCSetVisible((**storage).delegate, (**storage).mcVisible);
- MCSetControllerAttached((**storage).delegate, (**storage).mcAttached);
- movieRgn = MCGetWindowRgn((**storage).delegate, (WindowPtr) moviePort);
- SizeWindow((WindowPtr) moviePort, ((**movieRgn).rgnBBox).right - ((**movieRgn).rgnBBox).left,
- ((**movieRgn).rgnBBox).bottom - ((**movieRgn).rgnBBox).top, true);
- DisposeRgn(movieRgn);
-
- // Dispose back window.
- SelectWindow((**storage).backWindow);
- DisposeWindow((**storage).backWindow);
- (**storage).fadeStatus = false;
- }
- FadeInOut(myDevice, false, 60);
-
- SetPort(savePort);
- SetGDevice(saveGD);
- }
-